/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufscar.compiladores.ast;

import br.ufscar.compiladores.lexer.Symbol;

/**
 *
 * @author takeshi
 */

public class UnaryExpr extends Expr {
    
    private Expr expr;
    private int op;
    
    public UnaryExpr(Expr expr, int op) {
        this.expr = expr;
        this.op = op;
    }

    public void genC(PW pw, boolean putParenthesis) {
        switch (op) {
            case Symbol.PLUS:
                pw.out.print("+");
                break;
            case Symbol.MINUS:
                pw.out.print("-");
                break;
            case Symbol.NOT:
                pw.out.print("!");
                break;
        }
        expr.genC(pw, false);
    }

    public Type getType() {
        return expr.getType();
    }
}
